package com.cx.usercenter.service.impl;

import com.cx.usercenter.entity.BonusEventLog;
import com.cx.usercenter.dao.BonusEventLogDao;
import com.cx.usercenter.service.BonusEventLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (BonusEventLog)表服务实现类
 *
 * @author ThinkPad
 * @since 2021-09-09 14:42:42
 */
@Service("bonusEventLogService")
public class BonusEventLogServiceImpl implements BonusEventLogService {
    @Resource
    private BonusEventLogDao bonusEventLogDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public BonusEventLog queryById(Integer id) {
        return this.bonusEventLogDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<BonusEventLog> queryAllByLimit(int offset, int limit) {
        return this.bonusEventLogDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param bonusEventLog 实例对象
     * @return 实例对象
     */
    @Override
    public BonusEventLog insert(BonusEventLog bonusEventLog) {
        this.bonusEventLogDao.insert(bonusEventLog);
        return bonusEventLog;
    }

    /**
     * 修改数据
     *
     * @param bonusEventLog 实例对象
     * @return 实例对象
     */
    @Override
    public BonusEventLog update(BonusEventLog bonusEventLog) {
        this.bonusEventLogDao.update(bonusEventLog);
        return this.queryById(bonusEventLog.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.bonusEventLogDao.deleteById(id) > 0;
    }
}